package cn.acewill.yxd.yunxundian.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import cn.acewill.yxd.yunxundian.R;
import cn.acewill.yxd.yunxundian.model.ToolMainBean;


/**
 * Created by XXX on 2017/4/3.
 */
public class ToolMainAdapter extends BaseAdapter{
    private Context context;
    private ArrayList<ToolMainBean> list;

    public ToolMainAdapter(Context context, ArrayList<ToolMainBean> list){
        this.context=context;
        this.list=list;
    }
    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.message_warm,parent,false);
            holder=new ViewHolder();
            holder.ToolTitle= (TextView) convertView.findViewById(R.id.msgTitle);
            holder.ToolDesc= (TextView) convertView.findViewById(R.id.msgContent);
            holder.lookAll= (TextView) convertView.findViewById(R.id.lookAll);
            convertView.setTag(holder);
        }
        else{
            holder= (ViewHolder) convertView.getTag();
        }
        ToolMainBean bean=list.get(position);
        holder.ToolTitle.setText(bean.getToolTitle());
        holder.ToolDate.setText(bean.getToolDate());
        holder.ToolDesc.setText(bean.getToolDesc());
        holder.lookAll.setText("查看全部文档");
        return convertView;
    }

    class ViewHolder{
        TextView ToolTitle;
        TextView ToolDate;
        TextView ToolDesc;
        TextView lookAll;
    }
}
